import {Space} from "antd";
import {memo, useMemo} from "react";

interface PageProps {
  nodeData: any;
  setCurrentRow: any
  handleModalVisible: any;
}

const TitleRender: React.FC<PageProps> = memo((props) => {
  const {nodeData, setCurrentRow, handleModalVisible} = props
  const handleAdd = useMemo(() => {
    return (node: any) => {
      setCurrentRow({
        parentId: node.id
      })
      handleModalVisible(true)
    }
  },[nodeData,setCurrentRow,handleModalVisible])

  const handleUpdate = useMemo(()=>{
    return (node: any)=>{

      setCurrentRow({
        ...node
      });
     handleModalVisible(true)

    }
  },[nodeData,setCurrentRow,handleModalVisible])
  return <div>
    <Space>
      <span>   {nodeData.name}</span>
      <a onClick={() => handleAdd(nodeData)}>新增</a>
      <a onClick={() => handleUpdate(nodeData)}>编辑</a>
      <a>删除</a>
    </Space>
  </div>
})

export default TitleRender
